<template>
	<view>
		<view class="smart-padding-wrap">
			<view class="item">可自动获得焦点</view>
			<view > <input class="smart-input" placeholder="可自动获得焦点" focus="true"/></view>
			
			<view class="item">右下角显示搜索</view>
			<view > <input class="smart-input" placeholder="右下角显示搜索" confirm-type="search"/></view>
			
			<view class="item">控制最大输入长度</view>
			<view > <input class="smart-input" placeholder="控制最大输入长度" maxlength="10"/></view>
			
			<view class="item">同步获取输入值
			<text style="color: antiquewhite;">{{inputValue}}</text></view>
			<view > <input class="smart-input" placeholder="同步获取输入值" @input="onKeyInput"/></view>
			
			<view class="item">数字输入</view>
			<view > <input class="smart-input" placeholder="数字输入" type="number"/></view>
			
			<view class="item">密码输入</view>
			<view > <input class="smart-input" placeholder="密码输入" type="text"  password="true"/></view>
			
			<view class="item">带小数的输入</view>
			<view > <input class="smart-input" placeholder="带小数的输入" type="digit"/></view>
			
			<view class="item">身份证输入</view>
			<view > <input class="smart-input" placeholder="身份证输入" type="idcard"/></view>
			
			<view class="item">带清除按钮</view>
			<view class="wrapper"> <input class="smart-input" placeholder="带清除按钮" value="clearinputValue" @input="clearInput"/></view>
			<text v-if="showClearIcon" @click="clearIcon" class="uni-icon">&$xe434</text>
			<view class="item">可查看密码</view>
			<view class="wrapper">
		 <input class="smart-input" placeholder="可查看密码" :password="showPassword"/>
		 <text class="uni-icon" :class="[!showPassword ? 'eye-active' : '']" @click="changePassword">&#xe568</text>
		 </view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				inputValue:'',
				showPassword:true,
				clearinputValue:'',
				showClearIcon:false
			}
		},
		methods: {
			onKeyInput:function(event){
				this.inputValue = event.detail.value;
			},
			clearInput: function(event){
				this.clearinputValue = detail.value;
				if(event.detail.value.lenght > 0) this.showClearIcon = true;
				else this.showClearIcon = false;
			},
			clearIcon: function(event){
				this.clearinputValue = '';
				this.showClearIcon = false;
			},
			changePassword: function(){
				this.showPassword = !this.showPassword;
			},
		}
	}
</script>

<style>

</style>
